package com.example.design.shejimoshi.action.state.状态机实现方式三状态模式.inter;

import com.example.design.shejimoshi.action.state.enums.State;
import com.example.design.shejimoshi.action.state.状态机实现方式三状态模式.MarioStateMachine;

/**
 * @Description 初始小马里奥
 * @date 2022/11/2 13:23
 * @Author liuzhihui
 * @Version 1.0
 */
public class SmallMario extends AbstractIMario {
    private MarioStateMachine marioStateMachine;

    public SmallMario(MarioStateMachine marioStateMachine) {
        this.marioStateMachine = marioStateMachine;
    }

    @Override
    public State getName() {
        return State.SMALL;
    }

    @Override
    public void obtainMushRoom() {
        marioStateMachine.setCurrentState(new SuperMario(marioStateMachine));
        marioStateMachine.setScore(marioStateMachine.getScore() + 100);
    }

    @Override
    public void obtainCape() {
        marioStateMachine.setCurrentState(new CapeMario(marioStateMachine));
        marioStateMachine.setScore(marioStateMachine.getScore() + 200);
    }

    @Override
    public void obtainFireFlower() {
        marioStateMachine.setCurrentState(new FireMario(marioStateMachine));
        marioStateMachine.setScore(marioStateMachine.getScore() + 300);
    }

    @Override
    public void obtainMonster() {
        marioStateMachine.setCurrentState(this);
        marioStateMachine.setScore(marioStateMachine.getScore());
    }
}
